﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace _0712502_0712504_DesignPatternGame
{
    /// <summary>
    /// Nhà máy chứa sẵn các mẫu Turret của Tank
    /// </summary>
    /// 

    public class TankTurretFactory : GameObjectFactory
    {        
        public override void InitPrototypes()
        {          
            _nprototype = 7;
            _prototypes = new TankTurretModel[_nprototype];
            
            _prototypes[(int)IDTank.idPlayerTankLevel1] = new TankTurretModel(IDTankturret.idPlayerTankLevel1, 250,30); //Player Tank Lv1 Turret
            _prototypes[(int)IDTank.idPlayerTankLevel1].InitModel(GameResourceContainer.ImageManager.PlayerTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27,27));
            _prototypes[(int)IDTank.idPlayerTankLevel1].SpriteModel.itexture2d = 0;            
                                    
            _prototypes[(int)IDTank.idPlayerTankLevel2] = new TankTurretModel(IDTankturret.idPlayerTankLevel2,250, 40); //Player Tank Lv2 Turret
            _prototypes[(int)IDTank.idPlayerTankLevel2].InitModel(GameResourceContainer.ImageManager.PlayerTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idPlayerTankLevel2].SpriteModel.itexture2d = 1;
            
            _prototypes[(int)IDTank.idPlayerTankLevel3] = new TankTurretModel(IDTankturret.idPlayerTankLevel3,250,50); //Player Tank Lv3 Turret
            _prototypes[(int)IDTank.idPlayerTankLevel3].InitModel(GameResourceContainer.ImageManager.PlayerTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idPlayerTankLevel3].SpriteModel.itexture2d = 2;         

            _prototypes[(int)IDTank.idTank1] = new TankTurretModel(IDTankturret.idTank1,250,30); //Com Tank 1 Turret
            _prototypes[(int)IDTank.idTank1].InitModel(GameResourceContainer.ImageManager.ComTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank1].SpriteModel.itexture2d = 0;          

            _prototypes[(int)IDTank.idTank2] = new TankTurretModel(IDTankturret.idTank2,250,40); //Com Tank 2 Turret
            _prototypes[(int)IDTank.idTank2].InitModel(GameResourceContainer.ImageManager.ComTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank2].SpriteModel.itexture2d = 1;
            _prototypes[(int)IDTank.idTank2].SpriteModel.Origin = new Vector2(27, 27);

            _prototypes[(int)IDTank.idTank3] = new TankTurretModel(IDTankturret.idTank3,250,50); //Com Tank 3 Turret
            _prototypes[(int)IDTank.idTank3].InitModel(GameResourceContainer.ImageManager.ComTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank3].SpriteModel.itexture2d = 2;
            
            _prototypes[(int)IDTank.idTank4] = new TankTurretModel(IDTankturret.idTank4,250,50); //Com Tank 4 Turret
            _prototypes[(int)IDTank.idTank4].InitModel(GameResourceContainer.ImageManager.ComTankTurret, new Rectangle(0, 0, 54, 54), new Vector2(27, 27));
            _prototypes[(int)IDTank.idTank4].SpriteModel.itexture2d = 3;
            
        }
        public override VisibleGameEntity CreateObject(int idx)
        {
            if ((idx < 0) || (idx >= _nprototype))
            {
                return null;
            }

            return _prototypes[idx].Clone();
        }
    }
}
